﻿using System;

namespace WindowsAPI.Hooks
{
    public partial class Hook
    {
        public event EventHandler<HookEventArgs> Event;
        protected virtual void OnEvent(HookEventArgs Args)
        {
            var lv_Handlers = Event;
            if(lv_Handlers != null)
                lv_Handlers.Invoke(this, Args);
        }
        private bool OnEvent(int Code, IntPtr wParams, IntPtr lParams, out IntPtr Result)
        {
            var args = new HookEventArgs(Code, wParams, lParams);
            OnEvent(args);
            Result = args.Result;
            return args.Interrupt;
        }

        public event EventHandler EnableChanged;
        protected virtual void OnEnableChanged(EventArgs Args)
        {
            var lv_Handlers = EnableChanged;
            if(lv_Handlers != null)
                lv_Handlers.Invoke(this, Args);
        }
        private void OnEnableChanged() { OnEnableChanged(EventArgs.Empty); }
    }
}
